﻿@{
    ViewBag.Title = ViewBag.siteName + " - Chi tiết đơn hàng";
    ViewBag.Description = ViewBag.htmlDescription;
    ViewBag.Keywords = ViewBag.htmlKeywords;
}
@model BDShop.Models.OrderModels
@using BDShop.Business;
@using BDShop.Business.Cache;
@using BDShop.Entities;
@using BDShop.Configuration;
@using BDShop.Framework.Extensions;
@using BDShop.Utilities.Managers;
@using BDShop.Web;
@using BDShop.Resources;

<!--Middle Part Start-->

    <div id="content">
        <!--Breadcrumb Part Start-->
        <div class="breadcrumb"><a href="/">Trang chủ</a> » <a href="/thong-tin-tai-khoan.html">Tài khoản</a> » <a href="#">Chi tiết đơn hàng</a> </div>
        <!--Breadcrumb Part End-->
        <h1>Chi tiết đơn hàng</h1>
        <div class="checkout">
            <div class="checkout-heading">Thông tin đặt hàng</div>
            <div class="checkout-content">
                <table class="form">
                    <tbody>
                        @{
                            string cityName = CityService.GetByID(Model.city).Name;
                            string districtName = DistrictService.GetByID(Model.district).Name;
                        }
                        <tr>
                            <td> Họ và tên:</td>
                            <td>
                                @Html.Label(Model.fullName,new{@class="large-field",@id="fullname"})
                            </td>
                        </tr>
                        <tr>
                            <td> Số điện thoại:</td>
                            <td>
                                @Html.Label(Model.mobile,new{@class="large-field",@id="mobile"})
                               
                            </td>
                        </tr>
                        <tr>
                            <td> Giới tính:</td>
                            <td>
                                @Html.Label((Model.gender==1)?"Nam":"Nữ",new{@class="large-field",@id="gender"})
                            </td>
                        </tr>
                        <tr>
                            <td>Tỉnh / Thành phố:</td>
                            <td>
                                @Html.Label(cityName,new{@class="large-field",@id="city"})
                                
                            </td>
                        </tr>
                        <tr>
                            <td> Quận / Huyện:</td>
                            <td>
                                @Html.Label(districtName,new{@class="large-field",@id="city"})
                            </td>
                        </tr>
                        <tr>
                            <td>Địa chỉ:</td>
                            <td>
                                @Html.Label(Model.address,new{@class="large-field",@id="address"})
                               
                            </td>
                        </tr>
                        <tr>
                            <td>Phương thức thanh toán:</td>
                            <td>
                                @Html.Label(FO.ResourceManager.GetEnumString((PaymentMethod)Model.paymentMethod),new{@class="large-field",@id="address"})
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>

        <div class="checkout">
            <div class="checkout-heading">Chi tiết đơn hàng</div>
            <div class="checkout-content">
                <div class="checkout-product">
                    <table>
                        <thead>
                            <tr>
                                <td>Hình ảnh</td>
                                <td class="name">Tên sản phẩm</td>
                                <td class="model">Model</td>
                                <td class="quantity">Số lượng</td>
                                <td class="price">Giá</td>
                                <td class="total">Tổng cộng</td>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (var order in (List<BDShop.Entities.OrderDetail>)ViewBag.OrderDetail)
                            {
                                ProductCacheComplex product = ProductCache.Instance.Get().Where(p => p.ID == order.ProductID).FirstOrDefault();
                                Constant property = ConstantCache.Instance.Get().Where(c => c.Value == order.PropertyID).FirstOrDefault();
                                int total = order.Price * order.Quantity;

                                string[] categoryDefinition = null;
                                if (!string.IsNullOrEmpty(product.CategoryDefinition))
                                {
                                    categoryDefinition = product.CategoryDefinition.Split('|')[0].Split('#');
                                }
                                var url = UrlManager.ProductDetailUrl(product.ID, product.Name, categoryDefinition);
                                <tr>
                                    <td class="image"><a href="@url">
                                        <img style="width: 45px" class="lazy" data-original="@Path.Combine(BDShopConfiguration.Storage.MainImagePath, product.MainImage)" src="@Path.Combine(BDShopConfiguration.Storage.MainImagePath, product.MainImage)" alt="@product.Name" /></a></td>
                                    <td class="name"><a href="@url">@product.Name</a></td>
                                    <td class="model">@property.Description</td>
                                    <td class="quantity">@order.Quantity</td>
                                    <td class="price">@order.Price.ToCurrencyString(false, true)</td>
                                    <td class="total">@total.ToCurrencyString(false, true)</td>
                                </tr>
                            }
                        </tbody>
                        <tfoot>
                            <tr>
                               
                                <td class="price" colspan="5"><b>Chi phí vận chuyển:</b></td>
                                <td class="total">@Model.shippingCost.ToCurrencyString(false, true)</td>
                            </tr>
                            <tr>
                                <td class="price" colspan="5"><b>Thành tiền:</b></td>
                                <td class="total">@Model.total.ToCurrencyString(false, true)</td>
                            </tr>
                        </tfoot>
                    </table>
                </div>
               
            </div>
        </div>
    </div>

<!--Middle Part End-->
<div class="clear"></div>
